using System;
using System.Linq;
using System.Collections.Generic;

using DemoApp.DataAccess;

using EntModApp.EntServices.Business;
using EntModApp.EntServices.Data;

namespace DemoApp.BusinessLayer 
{
  public partial class FavoriteDerivedObjectRepository : 
    IFavoriteDerivedObjectRepository 
  {
    public IBusinessObjectCollection<IFavoriteDerived> RetrieveAll()
    {
      var query = new FavoriteDerivedLoadSettings();
      return Retrieve(query);
    }

    public IBusinessObjectCollection<IFavoriteDerived> Retrieve(FavoriteDerivedLoadSettings query)
    {
      query = FavoriteDerivedLoadSettings.FromFavoriteDerivedLoadSettings(query);
      if (query.AsReadonly)
      {
        var result = CslaFavoriteDerivedInfoCollection.GetFavoriteDerivedInfoCollection(query);
        return result;
      }
      else
      {
        var result = CslaFavoriteDerivedEditCollection.GetFavoriteDerivedEditCollection(query);
        return result;
      }
    }

    public IFavoriteDerived RetrieveOne(FavoriteDerivedLoadSettings query)
    {
      query = FavoriteDerivedLoadSettings.FromFavoriteDerivedLoadSettings(query);
      if (query.AsReadonly)
      {
        var result = CslaFavoriteDerivedInfoCollection.GetFavoriteDerivedInfoCollection(query);
        return result.FirstOrDefault<IFavoriteDerived>();
      }
      else
      {
        var result = CslaFavoriteDerivedEditCollection.GetFavoriteDerivedEditCollection(query);
        return result.FirstOrDefault<IFavoriteDerived>();
      }
    }

    public int Count()
    {
      return Count(null);
    }

    public int Count(FavoriteDerivedLoadSettings query)
    {
      query = FavoriteDerivedLoadSettings.FromFavoriteDerivedLoadSettings(query);
      return CslaFavoriteDerivedInfoCollection.GetCount(query);
    }

    public IFavoriteDerived New()
    {
      return CslaFavoriteDerivedEdit.New();
    }

    public void Save(IBusinessObjectCollection<IFavoriteDerived> collection)
    {
      throw new NotImplementedException();
    }

    public void Save(IFavoriteDerived obj)
    {
      throw new NotImplementedException();
    }
  }
}
